from PyPDF2 import PdfFileWriter, PdfFileReader

output = PdfFileWriter()
input1 = PdfFileReader(open(r"C:\Users\it\Documents\WXWork\1688851751719099\WeDrive\医渡云\IHS血液病攻坚小组\威廉姆斯血液学（第9版）中文(高清).pdf", "rb"))

# print how many pages input1 has:
print(f"document1.pdf has {input1.getNumPages()} pages.")

output.addPage(input1.getPage(25))
output.addPage(input1.getPage(26))

# # add some Javascript to launch the print window on opening this PDF.
# # the password dialog may prevent the print dialog from being shown,
# # comment the the encription lines, if that's the case, to try this out
# output.addJS("this.print({bUI:true,bSilent:false,bShrinkToFit:true});")
#
# # encrypt your new PDF and add a password
# password = "xj02"
# output.encrypt(password)

# finally, write "output" to document-output.pdf
outputStream = open(r"C:\Users\it\Documents\WXWork\1688851751719099\WeDrive\医渡云\IHS血液病攻坚小组\PyPDF2-output.pdf", "wb")
output.write(outputStream)
